OtpFieldStyle

Visual style of an OtpField.

Sizes are in points at the default text size and grow with Dynamic Type (scaled with fontTextStyle). minCellWidth and minCellHeight below 44 are raised to 44. focusedBorderWidth must be larger than borderWidth so focus and error are never communicated by color alone. groupSize draws a decorative separator between groups of digits (3 gives "123 - 456") without changing the code; 0 means no grouping. Separators are drawn only when the code length splits into equal groups, so 3 groups a 6-digit code but leaves 4- and 8-digit codes ungrouped. placeholder is drawn in empty cells and is hidden from VoiceOver; null or empty means none. errorTextStyle is the text style of the visible error message. cornerRadius is capped at half the cell size, so a large value (for example .greatestFiniteMagnitude) with equal minCellWidth and minCellHeight gives round cells. glass opts in to an iOS 26 Liquid Glass backdrop behind the cell row; the cells stay solid, so the contrast of digits, borders, focus, and errors is unchanged. Earlier iOS versions draw no backdrop. Use withGlass to turn it on. liftFocusedCell raises the focused cell slightly with a shadow, in addition to its thicker border; the movement is skipped under Reduce Motion. Use withFocusLift to turn it off. Create instances with OtpFieldDefaults.style.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Contrast problems of colors for the current trait collection; empty when compliant.

Link copied to clipboard
Link copied to clipboard
val errorTextStyle: UIFontTextStyle
Link copied to clipboard
Link copied to clipboard
val font: UIFont
Link copied to clipboard
val fontTextStyle: UIFontTextStyle
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Minimum cell height in points at the default text size, never below 44.

Link copied to clipboard

Minimum cell width in points at the default text size, never below 44.

Link copied to clipboard

Glyph drawn in empty cells, or null.

Functions

Link copied to clipboard

Copy with cornerRadius; a value of at least half the cell size gives round cells.

Link copied to clipboard

Copy with the focused cell lift on or off.

Link copied to clipboard

Copy with the Liquid Glass backdrop on or off.

Link copied to clipboard

Copy with groupSize; see OtpFieldStyle for when separators are drawn.

Link copied to clipboard

Copy with minimum cell width and height in points; values below 44 are raised to 44.